package com.carleasoft.mps.cms.business.repairs.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.carleasoft.mps.cms.business.repairs.bean.entity.RepairsGroup;
import com.carleasoft.mps.cms.business.repairs.bean.entity.VehicleMessage;
import com.carleasoft.mps.cms.business.repairs.bean.po.*;
import com.carleasoft.mps.cms.business.repairs.bean.vo.QueryIsDealPersonVo;
import com.carleasoft.mps.cms.business.repairs.bean.vo.VehicleMessageDetailVo;
import com.carleasoft.mps.cms.business.repairs.bean.vo.VehicleStatisticsVo;
import com.carleasoft.mps.cms.business.repairs.service.VehicleMessageService;
import com.carleasoft.mps.core.result.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * <p>
 * 装备报修 前端控制器
 * </p>
 *
 * @author fan
 * @since 2023-06-02
 */
@RestController
@RequestMapping("/vehicleMessage")
public class VehicleMessageController {
    @Autowired
    private VehicleMessageService vehicleMessageService;

    /**
     * 装备报修添加接口
     */
    @PostMapping("/vehicleAdd")
    public R vehicleAdd(@RequestBody VehicleMessageAddOrEditPo vehicleMessageAddOrEditPo) {
        return R.ok(vehicleMessageService.vehicleAdd(vehicleMessageAddOrEditPo));
    }

    /**
     * 导入装备报修
     * @param file
     * @return
     */
    @PostMapping("/vehicleExcel")
    public R vehicleExcel(@RequestPart("file") MultipartFile file) {
        boolean isOk = vehicleMessageService.vehicleExcel(file);
        return R.ok(isOk);
    }

    /**
     * 装备报修分页接口
     */
    @PostMapping("/vehiclePage")
    public R<Page<VehicleMessage>> vehiclePage(@RequestBody VehicleMessagePagePo vehicleMessagePagePo) {
        return R.ok(vehicleMessageService.vehiclePage(vehicleMessagePagePo));
    }

    /**
     * 我的装备报修分页接口
     */
    @PostMapping("/myVehiclePage")
    public R<Page<VehicleMessage>> myVehiclePage(@RequestBody VehicleMessagePagePo vehicleMessagePagePo) {
        return R.ok(vehicleMessageService.myVehiclePage(vehicleMessagePagePo));
    }

    /**
     * 装备报修详情接口
     */
    @PostMapping("/vehicleDetail")
    public R<VehicleMessageDetailVo> vehicleDetail(@RequestBody VehicleMessage vehicleMessage) {
        return R.ok(vehicleMessageService.vehicleDetail(vehicleMessage));
    }

    /**
     * 装备报修处理接口
     */
    @PostMapping("/vehicleDeal")
    public R<Boolean> vehicleDeal(@RequestBody VehicleMessageDealPo vehicleMessageDealPo) {
        return R.ok(vehicleMessageService.vehicleDeal(vehicleMessageDealPo));
    }

    /**
     * 装备报修维修反馈接口
     */
    @PostMapping("/vehicleFeedback")
    public R<Boolean> vehicleFeedback(@RequestBody VehicleFeedbackPo vehicleFeedbackPo) {
        return R.ok(vehicleMessageService.vehicleFeedback(vehicleFeedbackPo));
    }

    /**
     * 装备报修派单人员查询
     */
    @PostMapping("/sendPersonListVeh")
    public R<List<RepairsGroup>> sendPersonList(@RequestBody SendPersonListPo sendPersonListPo) {
        return R.ok(vehicleMessageService.sendPersonList(sendPersonListPo));
    }

    /**
     * 重新派工接口
     */
    @PostMapping("/anewVeh")
    public R anew(@RequestBody AnewPo anewPo) {
        return R.ok(vehicleMessageService.anew(anewPo));
    }

    /**
     * 查询当前登录人是否是综合处理人
     */
    @PostMapping("/queryIsDealPersonVeh")
    public R<QueryIsDealPersonVo> queryIsDealPerson() {
        return R.ok(vehicleMessageService.queryIsDealPerson());
    }

    /**
     * 导出装备报修记录
     */
    @PostMapping("/exportVeh")
    public R export(@RequestBody VehicleMessagePagePo vehicleMessagePagePo, HttpServletResponse response) {
        return R.ok(vehicleMessageService.export(vehicleMessagePagePo, response));
    }

    /**
     * 办公统计-装备报修
     */
    @PostMapping("/online/statisticsVeh")
    public R<VehicleStatisticsVo> statistics() {
        return R.ok(vehicleMessageService.statistics());
    }

    /**
     * 办公统计-装备报修-年度报修数量统计
     */
    @PostMapping("/online/statistics/theYearVeh")
    public R statisticsTheYear() {
        return R.ok(vehicleMessageService.statisticsTheYear());
    }

    /**
     * 办公统计-装备报修-维修率统计
     */
    @PostMapping("/online/statistics/MaintainRateVeh")
    public R MaintainRate() {
        return R.ok(vehicleMessageService.MaintainRate());
    }
}

